//
//  FilterView.m
//  bitcoin
//
//  Created by  旺链 on 2018/5/29.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "FilterView.h"

@interface FilterView()

@property (nonatomic,strong)NSMutableDictionary *backDic;

@end

@implementation FilterView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)awakeFromNib
{
    [super awakeFromNib];
    self.backDic = [NSMutableDictionary dictionaryWithDictionary:@{@"businessType":@"",@"currencyPay":@"",@"currencyTrade":@""}];
    
    self.selectBtn = self.allBtn;
    
    _chooseView.placeholder = @"请选择";
    _chooseView.listArray = @[@"BTC", @"ETH", @"USDT"];
    _chooseView.textColor = [UIColor colorWithHexString:@"#999999"];
}
//- (instancetype)initWithCoder:(NSCoder *)aDecoder
//{
//    if (self = [super initWithCoder:aDecoder]) {
//
//
//    }
//    return self;
//}
- (IBAction)selectClick:(UIButton*)sender {
    
    self.selectBtn = sender;
    NSInteger type = sender.tag-100;
    self.backDic[@"businessType"]=@(type);;
}
- (IBAction)confirmClick:(id)sender {
    
    self.backDic[@"currencyPay"]= self.tradeTf.text;
    self.backDic[@"currencyTrade"] = self.chooseView.text;
    if (self.filterBaclk) {
        self.filterBaclk(self.backDic);
    }
}

- (IBAction)resetClick:(id)sender {
    
    self.tradeTf.text = nil;
    self.selectBtn = self.allBtn;
}
- (IBAction)removeClick:(id)sender {
    [self removeFromSuperview];
}

- (void)setSelectBtn:(UIButton *)selectBtn
{
    if (_selectBtn) {
        
        _selectBtn.backgroundColor = [UIColor colorWithHexString:@"#2E3145"];
        [_selectBtn setBackgroundImage:nil forState:UIControlStateNormal];
    }
    
    selectBtn.backgroundColor = [UIColor clearColor];
    [selectBtn setBackgroundImage:[UIImage imageNamed:@"que-icon"] forState:UIControlStateNormal];
    
    _selectBtn = selectBtn;
}

@end
